package cn.iocoder.yudao.module.wine.controller.app.memberopenlog;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.wine.controller.app.memberopenlog.vo.AppMemberOpenLogRespVO;
import cn.iocoder.yudao.module.wine.dal.dataobject.guaranteerecord.GuaranteeRecordDO;
import cn.iocoder.yudao.module.wine.dal.dataobject.memberopenlog.MemberOpenLogDO;
import cn.iocoder.yudao.module.wine.service.guaranteerecord.GuaranteeRecordService;
import cn.iocoder.yudao.module.wine.service.memberopenlog.MemberOpenLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "App - 会员开通记录")
@RestController
@RequestMapping("/wine/member-open-log")
@Validated
public class AppMemberOpenLogController {

    @Resource
    private MemberOpenLogService memberOpenLogService;

    @Resource
    private GuaranteeRecordService guaranteeRecordService;


    @GetMapping("/get")
    @Operation(summary = "获得会员开通记录")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<AppMemberOpenLogRespVO> getMemberOpenLog(@RequestParam("memberTypeId") Long memberTypeId) throws InterruptedException {
        Thread.sleep(1000);
        MemberOpenLogDO memberOpenLog = memberOpenLogService.appGetMemberOpenLog(memberTypeId);
        return success(BeanUtils.toBean(memberOpenLog, AppMemberOpenLogRespVO.class));
    }

    @GetMapping("/get-guarantee")
    @Operation(summary = "获得团长缴费记录")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<GuaranteeRecordDO> getGuarantee(@RequestParam("id") Long id) throws InterruptedException {
        Thread.sleep(1000);
        GuaranteeRecordDO guaranteeRecord = guaranteeRecordService.appGetGuaranteeRecord(id);
        return success(BeanUtils.toBean(guaranteeRecord, GuaranteeRecordDO.class));
    }

}
